package com.freewater.cargotracker.domain.model.customer;

import org.apache.commons.lang3.Validate;

import java.io.Serializable;
import java.util.Objects;

public class CustomerNo implements Serializable {

    private static final long serialVersionUID = 1L;

    private String id;

    public CustomerNo(String id) {
        Validate.notNull(id, "id is required");
        this.id = id;
    }

    public String getIdString() {
        return this.id;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || this.getClass() != obj.getClass()) {
            return false;
        }
        final CustomerNo other = (CustomerNo) obj;
        return this.sameValueAs(other);
    }

    @Override
    public int hashCode() {
        return Objects.hash(this.id);
    }

    @Override
    public String toString() {
        return this.id;
    }

    boolean sameValueAs(CustomerNo other) {
        return other != null && this.id.equals(other.id);
    }
}
